#include "CheckingAccount.h"

CheckingAccount::CheckingAccount (double initialBalance, double fee)
:Account (initialBalance)
{
   transactionFee = 0.0;

   if ( fee > 0.0 )
      transactionFee = fee;

   if ( fee < 0.0 )
      cout << "Error: Initial fee cannot be negative.\n" << endl;
}

void CheckingAccount::credit (double amount)
{
    setBalance (getBalance () + amount);
    setBalance (getBalance () - transactionFee);
    cout << "$" << transactionFee << " transaction fee charged." << endl;
}

bool CheckingAccount::debit (double amount)
{
    if (!Account::debit (amount))
        return false;

    setBalance (getBalance () - transactionFee);
    cout << "$" << transactionFee << " transaction fee charged." << endl;
}
